<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/css/courseCss/courseManagement/coursecensus.css">
    <link rel="stylesheet" href="/css/userCss/userManagement/userList.css">
</head>
<body>
<div  class="layui-container" style="margin-left: 10%">
    <button type="button" onclick="zx()"> </button>
    <button type="button" onclick="yb()"> </button>
    <button type="button" onclick="zz()"> </button>
    <div id="main" style="width: 80%;height:800px;"></div>
</div>

<script src="/js/courseJs/courseManagement/jquery-3.6.0.js"></script>
<script src="/js/censusJs/dist/echarts.js"></script>
<script>
    var echarnum =null;
    var echarsort = null;
    $.ajax({
        type:"get",
        url:"/CourseCensus/getAllSOAC",
        data:{},
        async:false,
        success:function (res){
            console.log(res)
            echarnum = res.data
        }
    })
    $.ajax({
        type:"get",
        url:"/CourseCensus/getAllSort",
        data:{},
        async:false,
        success:function (res){
            echarsort = res.data
        }
    })
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));

    // 指定图表的配置项和数据
    var option = {
        title: {
            text: '课程上架数量'
        },
        tooltip: {},
        legend: {
            data: ['课程上架数量']
        },
        xAxis: {
            data: [echarnum[0].currDate, echarnum[1].currDate, echarnum[2].currDate, echarnum[3].currDate, echarnum[4].currDate, echarnum[5].currDate,echarnum[6].currDate]
        },
        yAxis: {},
        series: [
            {
                name: '课程上架数量',
                type: 'bar',
                data: [echarnum[0].curriculumId,echarnum[1].curriculumId,echarnum[2].curriculumId,echarnum[3].curriculumId,echarnum[4].curriculumId,echarnum[5].curriculumId,echarnum[6].curriculumId]
            }
        ]
    };
    var option1 = {
        title: {
            text: 'ECharts 入门示例'
        },
        tooltip: {},
        legend: {
            data: ['课程上架数量']
        },
        xAxis: {
            data: [echarnum[0].currDate, echarnum[1].currDate, echarnum[2].currDate, echarnum[3].currDate, echarnum[4].currDate, echarnum[5].currDate,echarnum[6].currDate]
        },
        yAxis: {},
        series: [
            {
                name: '课程上架数量',
                type: 'line',
                data: [echarnum[0].curriculumId,echarnum[1].curriculumId,echarnum[2].curriculumId,echarnum[3].curriculumId,echarnum[4].curriculumId,echarnum[5].curriculumId,echarnum[6].curriculumId]
            }
        ]
    };
    var option2 = {
        series: [
            {
                type: 'pie',
                data: [
                    {
                        value: echarsort[0].curriculumId,
                        name: echarsort[0].classificationName
                    },
                    {
                        value: echarsort[1].curriculumId,
                        name: echarsort[1].classificationName
                    },
                    {
                        value: echarsort[2].curriculumId,
                        name: echarsort[2].classificationName
                    },
                    {
                        value: echarsort[3].curriculumId,
                        name: echarsort[3].classificationName
                    },
                    {
                        value: echarsort[4].curriculumId,
                        name: echarsort[4].classificationName
                    }
                ]
            }
        ]
    };

    // 使用刚指定的配置项和数据显示图表。
    option && myChart.setOption(option);
    function zx(){
        option1 && myChart.setOption(option1)
    }
    function yb(){
        option2 && myChart.setOption(option2)
    }
    function zz(){
        option && myChart.setOption(option)
    }
</script>
</body>
</html>